home *** CD-ROM | disk | FTP | other *** search
-
- // A return value returned by some of the functions.
- enum DrawReturn { ScreenCompletelyDrawn, DrewWall, WallOffScreen };
-
-
- class X_Clip
- {
- public:
- // Pointers for the linked list.
- X_Clip *pNext;
-
- // Tells the clipping routines what flags to set with this X_Clip.
- //X_ClipFlag TableFlag;
-
- // The x boundaries of this clip.
- WORD x;
- };
-
-
- // This structure is passed around in all the drawing routines.
- class ProcessWall
- {
- public:
- CLine *pLine;
- Player *pPlayer;
-
- // World coordinates.
- Fixed x1, y1, x2, y2;
-
- // Screen coordinates.
- WORD screenX1, screenX2;
-
- // Unclipped screen coordinates... screenX1 and screenX2 are clipped against
- // the screen sides in the x clipping table.
- WORD unclippedScreenX1, unclippedScreenX2;
-
- // Stuff for the Y coordinates.
- Fixed topSlope, bottomSlope;
- WORD yTopIntercept, yBottomIntercept;
-
- // Returned from clipping routines. They represent where on the Line
- // each new X coordinate lies.
- Fixed t1, t2;
-
- // The shade at each of the screen x coordinates.
- // (Put it through dr_ShadeLookup() first.)
- Fixed shade1, shade2;
-
- // The Line's normal, after rotation.
- Fixed normalX, normalY;
-
- // Filled in when transforming. Tells which side the player is looking at.
- SideDir viewSide;
-
- // The 'magic numbers' in texture mapping.
- // P is the origin.
- // M is the horizontal vector.
- // N is the vertical vector.
- Fixed Px, Py, Pz;
- Fixed Mx, My, Mz;
- Fixed Nx, Ny, Nz;
-
- Fixed Oa, Oc;
- Fixed Ha, Hc;
-
- // Used for texture mapping .. the original Origin and Horizontal points.
- Fixed originX, originZ, horzX, horzZ;
-
- // Lets the drawing routines know if they need to re-init the wall's texture variables.
- BOOL bTextureInitted;
-
- BOOL bFlippedX;
- };
-
-
- // Should be called when initting the engine. Loads and generates all the lookup tables.
- void dr_InitTables();
-
- // Regenerates any lookup tables that need to change when the screen is resized.
- void dr_GenerateLookups();
-
- // Renders the whole screen based on global variables like the player's position.
- void dr_DrawScreen();
-
- // Just initializes the transformation stuff from a Player's view.
- void dr_SetupTransformation( Player *pPlayer );
-
- // Should be called from the BSP routines. The BSP routines will determine which walls need to
- // be drawn, and call the appropriate functions in Draw.
- DrawReturn dr_DrawWall( CLine *pWall, SideDir viewSide );
-
- // Called by the BSP routines. Sees if the wall has an entire subtree out of view.
- SideDir dr_PruneTree( CLine *pLine );
-
- // Rotates and translates the wall.
- BOOL dr_TransformWall( ProcessWall *pWall );
-
- // Clips against the z=0 plane. ALSO gets the
- // shade at the first and last points since this
- // is the last time it's clipped in 3d.
- // Returns FALSE if the wall is behind the player
- // and doesn't need to be drawn.
- BOOL dr_ClipWall( ProcessWall *pWall );
-
- // Projects the vertices into screen coordinates.
- BOOL dr_ProjectWall( ProcessWall *pWall );
-
- // Clips the wall against the others drawn.
- // Returns FALSE if the wall doesn't clip right.
- // ALSO changes the shade values for shade1 and shade2
- // if it needs to clip the wall.
- DrawReturn dr_TableClipAndDrawWall( ProcessWall *pWall );
-
- // Returns an extra X clip.
- X_Clip *GetXClip();
-
- // Draws a horizontal section of a wall.
- void dr_DrawHorizontalStrip( ProcessWall *pWall, WORD xLeft, WORD xRight );
-
- // Draws line of a parallaxing sky..
- void dr_ParallaxLine( BYTE *pDrawTo, BYTE *pBuffer, BYTE *pPaletteMap, DWORD numPixels );
-
- // Draws a line of a wall.
- void dr_WallLine( BYTE *pDrawTo, BYTE *pBuffer, BYTE *pPaletteMap, Fixed bufferStartPos, WORD numPixels );
-
- // Draws the bottom line.
- void dr_BlankVLine( BYTE *pDrawTo, DWORD numPixels, DWORD lineAdd, BYTE color );
-
- // Draws the whole environment in 2D.
- void Draw2DEnvironment( CLineArray *pLines, CPointArray *pPoints, WORD xOffset, WORD yOffset, Fixed scale, WORD maxX, WORD maxY );
-
- // Just draws a solid line .. used to test projections.
- void dr_DrawLine( DWORD x1, DWORD y1, DWORD x2, DWORD y2, WORD maxX, WORD maxY, BYTE color );
-
- // Clips against an arbitrary Y line.
- // Returns the number of the point that got clipped .. (1=*pX1,*pY1 and 2=*pX2,*pY2).
- WORD dr_ClipAgainstLine( Fixed clipLine, Fixed *pX1, Fixed *pY1, Fixed *pX2, Fixed *pY2, Fixed *pT1, Fixed *pT2, BOOL bPositiveHalf );
-
- // Fixed math functions .. written in assembler.
- Fixed FDiv(Fixed numTop, Fixed numBottom);
- Fixed FMul(Fixed num1, Fixed num2);
-
-
- #pragma aux FDiv = \
- "cdq" \
- "shld edx, eax, 15" \
- "shl eax, 15" \
- "idiv ebx" \
- parm [ EAX ] [ EBX ] \
- modify [ EDX ] \
- value [ EAX ];
-
-
- #pragma aux FMul = \
- "test eax,eax" \
- "jz end" \
- "test edx,edx" \
- "jnz around" \
- "xor eax,eax" \
- "jmp end" \
- "around:" \
- "imul edx" \
- "add eax,32768" \
- "adc edx,0" \
- "shrd eax, edx, 15" \
- "end:" \
- parm [ EAX ] [ EDX ] \
- value [ EAX ];
-
-
-